from selenium.webdriver.common.by import By
from base.base_action import BaseAction


# 岗位管理页面
class PostManagePage(BaseAction):

    # 岗位管理按钮
    post_manage_btn = By.XPATH, "//span[text()='岗位管理']"

    # 第一个搜索框
    first_search = By.XPATH, "//input[@placeholder='搜索岗位']"

    # 状态筛选框
    second_search = By.XPATH, "//input[@placeholder='地图状态']"

    # 待发布
    no_publish_btn = By.XPATH, "/html/body/div[2]/div[1]/div[1]/ul/li[1]/span"

    # 已发布
    publish_btn = By.XPATH, "/html/body/div[2]/div[1]/div[1]/ul/li[2]/span"

    # 新建岗位按钮
    new_btn = By.XPATH, "//span[text()='新增岗位']"

    # 所属分类输入框
    classification_input = By.XPATH, "//input[@placeholder='选择所属分类']"

    # 选择分类
    d1 = By.XPATH, "/html/body/div[3]/div[1]/div[1]/div[1]/ul/li[1]/label/span[1]/span"

    # 空白区域
    blank_area = By.XPATH, "//span[text()='新建岗位']"

    # 岗位名称输入框
    post_name_input = By.XPATH, "//input[@placeholder='输入岗位名称']"

    # 确定按钮
    determine_btn = "document.getElementsByClassName('el-button el-button--primary')[6].click();"

    # 点击编辑
    edit_btn = "document.getElementsByClassName('operate-style')[0].click();"

    # 删除按钮
    remove_btn = "document.getElementsByClassName('operate-style')[3].click();"

    # 弹窗的确定按钮
    determine1_btn = By.XPATH, "//span[contains(text(),'确定')]"

    # 点击岗位管理按钮
    def click_post_manage_btn(self):
        return self.click(self.post_manage_btn)

    # 通过第一个搜索框进行搜索
    def input_first_search(self, content):
        return self.input(self.first_search, content)

    # 点击状态筛选框
    def click_second_search(self):
        return self.click(self.second_search)

    # 点击待发布
    def click_no_publish_btn(self):
        return self.click(self.no_publish_btn)

    # 点击已发布
    def click_publish_btn(self):
        return self.click(self.publish_btn)

    # 点击新建按钮
    def click_new_btn(self):
        return self.click(self.new_btn)

    # 点击所属分类
    def click_classification_select(self):
        return self.click(self.classification_input)

    # 选择岗位分类
    def select_third_sort(self):
        self.click(self.d1)
        self.click(self.blank_area)

    # 输入岗位名称
    def input_post_name(self, content):
        return self.input(self.post_name_input, content)

    # 点击确定按钮
    def click_determine_btn(self):
        return self.execute_js(self.determine_btn)

    # 点击编辑
    def click_edit_btn(self):
        return self.execute_js(self.edit_btn)

    # 点击删除按钮
    def click_remove_btn(self):
        return self.execute_js(self.remove_btn)

    # 点击确定按钮
    def click_determine1_btn(self):
        return self.click(self.determine1_btn)







